//
//  MainTabBarController.m
//  LiteraryTune
//
//  Created by 神州四达 on 2018/1/15.
//  Copyright © 2018年 cxd. All rights reserved.
//

#import "MainTabBarController.h"
//#import "BookShelfViewController.h"
#import "BookMallViewController.h"
#import "PersonalCenterViewController.h"
#import "LibraryViewController.h"

#import "NewBookMallVC.h"

@interface MainTabBarController ()

@property (nonatomic, strong)LibraryViewController *bookShelfVC;
//@property (nonatomic, strong)BookMallViewController *bookMallVC;
@property (nonatomic, strong)NewBookMallVC *bookMallVC;
@property (nonatomic, strong)PersonalCenterViewController *personalVC;

@end

@implementation MainTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.tabBar.translucent = NO;
    [self addChildViewController];
}

- (void)addChildViewController {
    
    _bookShelfVC = [[LibraryViewController alloc] init];
    _bookShelfVC.title = @"书架";
    _bookShelfVC.tabBarItem.title = @"书架";
    _bookShelfVC.tabBarItem.image = [[UIImage imageNamed:@"BookShelf"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    _bookShelfVC.tabBarItem.selectedImage = [[UIImage imageNamed:@"shelfSelected"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    CXDCustomNavigationController *shelfNV = [[CXDCustomNavigationController alloc] initWithRootViewController:_bookShelfVC];
    [self addChildViewController:shelfNV];
    
//    _bookMallVC = [[BookMallViewController alloc] init];
    _bookMallVC = [NewBookMallVC new];
    _bookMallVC.title = @"书城";
    _bookMallVC.tabBarItem.title = @"书城";
    _bookMallVC.tabBarItem.image = [[UIImage imageNamed:@"BookMall"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    _bookMallVC.tabBarItem.selectedImage = [[UIImage imageNamed:@"mallSelected"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    CXDCustomNavigationController *mallNV = [[CXDCustomNavigationController alloc] initWithRootViewController:_bookMallVC];
    [self addChildViewController:mallNV];
   
    
    _personalVC = [[PersonalCenterViewController alloc] init];
    _personalVC.title = @"我的";
    _personalVC.tabBarItem.title = @"我的";
    _personalVC.tabBarItem.image = [[UIImage imageNamed:@"PersonalNormal"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    _personalVC.tabBarItem.selectedImage = [[UIImage imageNamed:@"personalSelected"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    CXDCustomNavigationController *perNV = [[CXDCustomNavigationController alloc] initWithRootViewController:_personalVC];
    [self addChildViewController:perNV];
    [UITabBar appearance].barTintColor = [UIColor whiteColor];
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:MainDarkGrayColor,NSForegroundColorAttributeName,[UIFont systemFontOfSize:14],NSFontAttributeName,NSBackgroundColorAttributeName,[UIColor whiteColor], nil] forState:UIControlStateNormal];
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:MainGreenColor,NSForegroundColorAttributeName,[UIFont systemFontOfSize:14],NSFontAttributeName,NSBackgroundColorAttributeName,[UIColor whiteColor], nil] forState:UIControlStateSelected];
    
    [self setSelectedIndex:1];
}

@end
